package com.kaaction.modules.crab.api;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dom4j.DocumentException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.kaaction.common.web.BaseController;
import com.kaaction.modules.crab.service.CrabAreaService;

@Controller
@RequestMapping(value = "/api/v1/crabAreaApi")
public class CrabAreaApi extends BaseController{
	
	@Autowired
	CrabAreaService crabAreaService;
	
	/**
	 * 获取省份
	 * 
	 * @param request
	 * @param response
	 * @throws UnsupportedEncodingException
	 * @throws DocumentException
	 */
	@RequestMapping(value = "/getProvince")
	public void selExchangeCouponProduct(HttpServletRequest request, HttpServletResponse response)
			throws UnsupportedEncodingException, DocumentException {
		super.writeAjaxResponse(response,crabAreaService.selectListProvince());
	}
	
	/**
	 * 获取城市
	 * 
	 * @param request
	 * @param response
	 * @throws UnsupportedEncodingException
	 * @throws DocumentException
	 */
	@RequestMapping(value = "/getCity")
	public void getCity(HttpServletRequest request, HttpServletResponse response)
			throws UnsupportedEncodingException, DocumentException {
		String province = request.getParameter("province");
		super.writeAjaxResponse(response,crabAreaService.selectListCity(province));
	}
	
	
	/**
	 * 获取区(县)
	 * 
	 * @param request
	 * @param response
	 * @throws UnsupportedEncodingException
	 * @throws DocumentException
	 */
	@RequestMapping(value = "/getCounty")
	public void getCounty(HttpServletRequest request, HttpServletResponse response)
			throws UnsupportedEncodingException, DocumentException {
		String city = request.getParameter("city");
		super.writeAjaxResponse(response,crabAreaService.selectListCounty(city));
	}
	

}
